home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / tptc17.zip / TPTCSYS.PAS < prev    next >
Pascal/Delphi Source File  |  1988-03-26  |  5KB  |  156 lines

  1.  
  2. (*
  3.  * TPTCSYS.PAS - System unit for use with Turbo Pascal --> C Translator
  4.  *
  5.  * (C) 1988 S.H.Smith (rev. 23-Mar-88)
  6.  *
  7.  * This unit is compiled to create 'TPTCSYS.UNS', which is automatically
  8.  * loaded on each TPTC run.   It defines the predefined environment from
  9.  * which programs are translated.
  10.  *
  11.  * Compile with:
  12.  *    tptc tptcsys -lower
  13.  *
  14.  * Create an empty tptcsys.uns if the file does not already exist.
  15.  *
  16.  * Note the special 'as replacement_name' clause used in some cases.
  17.  * When present, this clause causes the replacement_name to be used in
  18.  * place of the original name in the translated output.
  19.  *
  20.  *)
  21.  
  22. unit tptc_system_unit;
  23.  
  24. interface
  25.  
  26.    (* 
  27.     * Standard functions provided in Borland's system unit 
  28.     *
  29.     *)
  30.    
  31.    function Sin(n: real): real;
  32.    function Cos(n: real): real;
  33.    function Tan(n: real): real;
  34.    function Sqr(n: real): real;
  35.    function Sqrt(n: real): real;
  36.    function Trunc(r: real): longint;
  37.    function Round(r: real): real;
  38.    function Int(r: real): real;
  39.  
  40.    function Pred(b: integer): integer;
  41.    function Succ(b: integer): integer;
  42.    function Ord(c: char): integer;
  43.    function Hi(w: word): word;
  44.    function Lo(w: word): word;
  45.  
  46.    function MemAvail: longint;
  47.    function MaxAvail: longint;
  48.    procedure Dispose(var ptr);
  49.    procedure Mark(var ptr);
  50.    procedure Release(var ptr);
  51.       
  52.    procedure Assign(fd: text; name: string);
  53.    procedure Reset(var fd: text);
  54.    procedure ReWrite(var fd: text);
  55.    procedure Append(var fd: text);
  56.    procedure SetTextBuf(fd: text; var buffer; size: word);
  57.    procedure Seek(fd: text; rec: word);
  58.    function SeekEof(fd: text): boolean;
  59.       
  60.    var ParamCount: integer;
  61.    function ParamStr(n: integer): string;
  62.    
  63.    procedure Delete(s: string; posit,number: integer);
  64.    function Copy(s: string; from,len: integer): string;
  65.    procedure Val(s: string; var res: real; var code: integer);
  66.    procedure Move(var tomem; var fmmem; bytes: word);
  67.    procedure FillChar(var dest; size: integer; value: char);
  68.  
  69.    
  70.    (*
  71.     * Standard procedures with replacement names or modified
  72.     * parameter types
  73.     *
  74.     *)
  75.     
  76.    function Eof(fd: text): boolean        as feof;
  77.    procedure Flush(fd: text)              as fflush;
  78.    procedure Close(fd: text)              as fclose;
  79.    function UpCase(c: char): char         as toupper;
  80.    function Length(s: string): integer    as strlen;
  81.  
  82.    procedure Inc(b: byte);          {tptcmac.h macros}
  83.    procedure Dec(b: byte);
  84.  
  85.  
  86.    (* 
  87.     * Additional procedures called by translated code 
  88.     *
  89.     *)
  90.    
  91.    type 
  92.       setrec = set of char;
  93.       
  94.    function setof(element: byte {...}): setrec;
  95.    function inset(theset: setrec; item: byte): boolean;
  96.  
  97.    function scat(control: string {...}): string;
  98.       {concatenate strings according to printf style control and
  99.        return pointer to the result}
  100.        
  101.    function ctos(c: char): string;
  102.       {convert a character into a string}
  103.       
  104.    procedure sbld(dest: string; control: string {...});
  105.       {build a string according to a control string (works like sprintf
  106.        with with special handling to allow source and destination
  107.        variables to be the same)}
  108.        
  109.    function spos(key: string; str: string): integer;
  110.       {returns the position of a substring within a longer string}
  111.       
  112.    function cpos(key: char; str: string): integer;
  113.       {returns the position of a character within a string}
  114.       
  115.    function fscanv(var fd: text; control: string {...}): integer;
  116.       {functions like fscanf but allows whole-line reads into
  117.        string variables}
  118.        
  119.  
  120.    (* The following identfiers are 'builtin' to the translator and
  121.       should not be defined here.  If any of these are redefined, the
  122.       corresponding special translation will be disabled. *)
  123.       
  124.    (* 
  125.     *   function Pos(key: string; line: string): integer;
  126.     *   procedure Chr(i: integer): char;
  127.     *   procedure Str(v: real; dest: string);
  128.     *   procedure Exit;
  129.     *
  130.     *   var 
  131.     *      Mem:    array[0..$FFFF:0..$FFFF] of byte;
  132.     *      MemW:   array[0..$FFFF:0..$FFFF] of word;
  133.     *      Port:   array[0..$1000] of byte; {i/o ports}
  134.     *      PortW:  array[0..$1000] of word;
  135.     *
  136.     *)
  137.  
  138.  
  139.    (* 
  140.     * Extra identifiers needed when translating tpas3.0 sources
  141.     *
  142.     *)
  143.     
  144.    procedure MsDos(var reg);
  145.    procedure Intr(fun: integer; var reg);
  146.  
  147.    var
  148.       Lst:     text;
  149.       Con:     text;
  150.       Output:  text;
  151.       Input:   text;
  152.       
  153.  
  154. implementation
  155.  
  156.